<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use common\models\projectrepo\ProjectRepo;
use common\models\projectcontract\ProjectContract;
use common\models\projectsummary\ProjectSummary;
use common\models\project\Project;

/* @var $this yii\web\View */
/* @var $model common\models\project\Project */

$repoid = ProjectRepo::find()->where(['pr_id' => $model->id])->asArray()->one()['id'];
$contid = ProjectContract::find()->where(['pr_id' => $model->id])->asArray()->one()['id'];
$summid = ProjectSummary::find()->where(['pr_id' => $model->id])->asArray()->one()['id'];
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', '项目列表'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;

?>
<?php $this->beginBlock('siderbar'); ?>
<?= $this->render('//layouts/pro-menu') ?>
<?php $this->endBlock(); ?>
<div class="project-view">

    <p>
        <?= Html::a(Yii::t('app', '修改'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
        <?= Html::a(Yii::t('app', '删除'), ['delete', 'id' => $model->id], [
            'class' => 'btn btn-danger',
            'data' => [
                'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
                'method' => 'post',
            ],
        ]) ?>

        <?= Html::a(Yii::t('app', '修改申报书'), ['project-repo/update', 'id' => $repoid], ['class' => 'btn btn-info']) ?>
        <?= Html::a(Yii::t('app', '修改合同书'), ['project-contract/update', 'id' => $contid], ['class' => 'btn btn-primary']) ?>
        <?= Html::a(Yii::t('app', '修改总结报告'), ['project-summary/update', 'id' => $summid], ['class' => 'btn btn-success']) ?>

    </p>

    <?= DetailView::widget([
        'model' => $model,
        'attributes' => [
            'id',
            'name',
            'cname',

            [
                'attribute'=>'category',
                'value'=> Project::getArrayCategory()[$model->category],
            ],

            'management',
            'bearunit',
            'starttime',
            'endtime',
            'director',
            'funds',
            'surplus',

            [
                'attribute' => 'status',
                'value' => $model->getStatusLabel($model->status),
            ],

        ],
    ]) ?>
    <table class="table table-striped table-bordered detail-view">
        <tbody>
            <?php if(!empty($model->file)) { ?>
            <?php foreach ($model->file as $k=>$file) { ?>
            <tr>
                <th>项目文件名</th>
                <td><a href="<?=Yii::$app->params['setshow']; ?><?= $file; ?>"><?= $model->filename[$k] ?></a></td>
            </tr>
            <?php } ?>
            <?php } ?>
        </tbody>
    </table>

</div>
